// 表单字段类型
export type FieldType = 'input' | 'select' | 'radio' | 'checkbox' | 'date' | 'switch' | 'upload'

// 字段验证规则
export interface ValidationRule {
  message?: string
  pattern?: RegExp
  validator?: (value: any) => boolean | Promise<boolean>
  trigger?: 'blur' | 'change'
  required?: boolean
}

// 字段选项
export interface FieldOption {
  label: string
  value: string | number
  disabled?: boolean
}

// 字段定义
// 字段显隐规则
export interface VisibilityRule {
  field: string
  operator: '=' | '!=' | '>' | '<' | '>=' | '<=' | 'includes' | 'empty' | 'notEmpty'
  value?: any
  and?: VisibilityRule[]
  or?: VisibilityRule[]
}

// 修改 FormField 接口
export interface FormField {
  field: string
  label: string
  type: FieldType
  value?: any
  defaultValue?: any
  placeholder?: string
  rules?: ValidationRule | ValidationRule[]
  options?: FieldOption[]
  props?: Record<string, any>
  col?: number
  required?: boolean
  show?: boolean | ((values: any) => boolean) | Pick<VisibilityRule, 'and'> | VisibilityRule
  disabled?: boolean | ((values: any) => boolean)
}

// 表单布局
export interface FormLayout {
  labelWidth?: string | number
  labelPosition?: 'left' | 'right' | 'top'
  cols?: number
  gutter?: number
}

// 完整表单 Schema
export interface FormSchema {
  fields: FormField[]
  layout: FormLayout
  submitText?: string
  resetText?: string
}
